package com.hoshiicloud.commissioncalculation.feign.hystrix;

import com.hoshiicloud.commissioncalculation.feign.GoodsFeignService;
import com.hoshiicloud.commissioncalculation.feign.OrderFeignService;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.goods.entity.sku.ExtSku;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author ygd
 * @title: HystrixGoodsFeignFallback
 * @projectName hoshiicloud
 * @description: 商品熔断
 * @date 2019/9/5
 */
@Component
public class HystrixGoodsFeignFallback implements FallbackFactory<GoodsFeignService> {
    @Override
    public GoodsFeignService create(Throwable cause) {
        return new GoodsFeignService() {
            @Override
            public Response<ExtSku> getSkuById(Long id) {
                return Response.failed(cause.getMessage());
            }
        };
    }
}
